package com.alog.storage.presenter;

import com.alog.storage.Contants;
import com.alog.storage.net.BaseAPI;
import com.alog.storage.ui.activity.IBaseView;

public abstract class BasePresenter<T> implements BaseAPI.APICallback<T> {
    protected IBaseView iView;

    @Override
    public void onSuccess(int apiId, Object data) {
        if (iView != null) {
            iView.setData(apiId, data);
        }
    }

    @Override
    public void onFailure(int apiId, int code, String msg) {
        if (iView != null) {
            if (code == Contants.SERVER_CODE_LOGIN_TIMEOUT) {
                iView.login();
            } else {
                iView.showError();
            }
        }
    }
}
